project(yagf C CXX)
cmake_minimum_required(VERSION 2.6.0)
set (CMAKE_IN_SOURCE_BUILD TRUE)
set(SOURCES src/main.cpp src/mainform.cpp src/qgraphicsinput.cpp src/utils.cpp src/FileChannel.cpp src/spellchecker.cpp src/FileToolBar.cpp src/BlockAnalysis.cpp src/PageAnalysis.cpp src/SkewAnalysis.cpp src/CCAnalysis.cpp)
set(INT_SOURCES src/preload.c)
set(UIS src/mainform.ui)
set(MOC_HEADERS src/mainform.h src/FileChannel.h src/qgraphicsinput.h src/FileToolBar.h)
set (yagf_RCCS src/yagf.qrc)
set(QM_FILES yagf_ru.qm yagf_lt.qm yagf_de.qm yagf_pl.qm yagf_uk.qm)
set (LIB_PATH_SUFFIX )
add_definitions(-Wall -g)
find_package(Qt4 REQUIRED)
find_package(ASPELL REQUIRED)
include(${QT_USE_FILE})
qt4_wrap_ui(UI_HEADERS ${UIS})
qt4_wrap_cpp(MOC_SRCS ${MOC_HEADERS})
qt4_add_resources(yagf_RCC_SRCS ${yagf_RCCS})
include_directories( ${CMAKE_BINARY_DIR} )
add_executable(yagf ${SOURCES} ${UI_HEADERS} ${MOC_SRCS} ${yagf_RCC_SRCS} ${QM_FILES})
add_library(xspreload SHARED ${INT_SOURCES})
target_link_libraries(yagf ${QT_LIBRARIES} ${ASPELL_LIBRARIES})
add_custom_target(translations DEPENDS ${QM_FILES})
qt4_add_translation(yagf_ru.qm src/mainform.cpp ${MOC_SRCS} ${UI_HEADERS} src/yagf_ru.ts)
qt4_add_translation(yagf_lt.qm src/mainform.cpp ${MOC_SRCS} ${UI_HEADERS} src/yagf_lt.ts)
qt4_add_translation(yagf_de.qm src/mainform.cpp ${MOC_SRCS} ${UI_HEADERS} src/yagf_de.ts)
qt4_add_translation(yagf_pl.qm src/mainform.cpp ${MOC_SRCS} ${UI_HEADERS} src/yagf_pl.ts)
qt4_add_translation(yagf_uk.qm src/mainform.cpp ${MOC_SRCS} ${UI_HEADERS} src/yagf_uk.ts)
#QT4_CREATE_TRANSLATION(yagf_ru.qm src/mainform.cpp ${MOC_SRCS} ${UI_HEADERS} src/yagf_ru.ts)
#set(CMAKE_INSTALL_PREFIX /usr/)
if (NOT DEFINED  ${CMAKE_INSTALL_PREFIX})
set(CPACK_INSTALL_PREFIX /usr/)
set (CMAKE_INSTALL_PREFIX /usr/)
endif()
install_targets(/bin/ yagf)
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
        set (LIB_PATH_SUFFIX 64)
        set_property (GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS TRUE)
endif(CMAKE_SIZEOF_VOID_P EQUAL 8)
install_targets(/lib${LIB_PATH_SUFFIX}/yagf xspreload)
install(FILES ${QM_FILES} DESTINATION share/yagf/translations/)
#install(FILES COPYING DESCRIPTION README AUTHORS ChangeLog DESTINATION share/yagf/)
install(FILES yagf.png DESTINATION share/pixmaps/)
install(FILES yagf.png DESTINATION share/icons/hicolor/96x96/apps/)
install(FILES YAGF.desktop DESTINATION share/applications/)

#set(CPACK_PACKAGE_FILE_NAME yagf)
set(CPACK_PACKAGE_VENDOR "Andrei Borovsky, anb@symmetrica.net")
set(CPACK_PACKAGE_CONTACT ${CPACK_PACKAGE_VENDOR})
set(CPACK_SYSTEM_NAME "i586")
set(CPACK_BINARY_DEB ON)
set(CPACK_BINARY_RPM ON)
set(CPACK_BINARY_STGZ ON)
set(CPACK_BINARY_TGZ OFF)
set(CPACK_BINARY_TZ OFF)
set(CPACK_BINARY_TBZ2 OFF)
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Graphical front-end for cuneiform OCR tool")
set(CPACK_PACKAGE_VERSION 0.8.6)
set(CPACK_PACKAGE_VERSION_MAJOR "0")
set(CPACK_PACKAGE_VERSION_MINOR "8")
set(CPACK_PACKAGE_VERSION_PATCH "6")
set(CPACK_STRIP_FILES bin/yagf bin/libyagfpreload)
set(CPACK_SOURCE_TBZ2 "OFF")
set(CPACK_SOURCE_TGZ "ON")
set(CPACK_SOURCE_TZ "OFF")
set(CPACK_SOURCE_INSTALLED_DIRECTORIES "${CMAKE_SOURCE_DIR}/yagf-${CPACK_PACKAGE_VERSION}/;/")
set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/COPYING)
set(CPACK_PACKAGE_DESCRIPTION_FILE ${CMAKE_SOURCE_DIR}/DESCRIPTION)
set(CPACK_RESOURCE_FILE_README ${CMAKE_SOURCE_DIR}/README)
set(DEBIAN_PACKAGE_SECTION "text processing")
set(CPACK_RPM_PACKAGE_LICENSE "GPL v.3.0")
set (CPACK_RPM_PACKAGE_REQUIRES "libqt >= 4.5")
include(CPack)


